######################################
# 自定义添加文件
include Makefile.user

STFLASH=./Tools/st-flash-linux
JLINK = JLinkExe
JLINK_OPTIONS = -device stm32l476je -if swd -speed 1000
JLINKGDBSERVER = JLinkGDBServer $(JLINK_OPTIONS) $(JLINKGDBSERVER_OPTION)
FLASH_START_ADDRESS=0x0800C000
#LDFLAGS += -Wl,-Ttext=$(FLASH_START_ADDRESS)

flash: $(BUILD_DIR)/$(TARGET).bin
	$(STFLASH) --reset write $(BUILD_DIR)/$(TARGET).bin $(FLASH_START_ADDRESS)

flash.jlink:
	printf "r\nloadbin $(BUILD_DIR)/$(TARGET).bin $(FLASH_START_ADDRESS)\nr\ng\nq\n" > flash.jlink

jflash:$(BUILD_DIR)/$(TARGET).bin flash.jlink
	@echo "Using Jlink"
	$(JLINK) $(JLINK_OPTIONS) $(JLINKEXE_OPTION) flash.jlink



